<html>
<head><meta charset="utf-8"><title>dropck optimization · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html">dropck optimization</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="175960700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175960700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175960700">(Sep 18 2019 at 00:17)</a>:</h4>
<p>Not sure who all to bug about this -- maybe <span class="user-mention" data-user-id="116083">@pnkfelix</span> would know -- but it seems to me like for the most part, dropck should be able to not care about substituting concrete types in for generics. Currently, we do, which leads to problems like in <a href="https://github.com/rust-lang/rust/issues/4287" target="_blank" title="https://github.com/rust-lang/rust/issues/4287">https://github.com/rust-lang/rust/issues/4287</a></p>



<a name="175960757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175960757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175960757">(Sep 18 2019 at 00:18)</a>:</h4>
<p>AFAICT though</p>
<div class="codehilite"><pre><span></span>enum Perfect&lt;T&gt; {
    Tip(T),
    Fork(Box&lt;Perfect&lt;(T, T)&gt;&gt;),
}
</pre></div>


<p>should either pass dropck or not independent of what T is, right?</p>



<a name="175960909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175960909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175960909">(Sep 18 2019 at 00:21)</a>:</h4>
<p>In particular, the documentation in <a href="https://doc.rust-lang.org/nightly/nomicon/dropck.html" target="_blank" title="https://doc.rust-lang.org/nightly/nomicon/dropck.html">the nomicon</a> talks about how if T here was <code>&amp;'a i32</code> or so that could lead to problems, but since Drop impls must be equivalent to the struct definition, that seems like it shouldn't be a problem, right? i.e., either all T's are fine or none are, since dropck is overly conservative and "assumes" it has a <code>'a</code> in the T or so</p>



<a name="175971801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175971801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175971801">(Sep 18 2019 at 05:27)</a>:</h4>
<p>I thought The problem in 4287 was due to the enum definition itself (namely the non-uniform type-recursion)</p>



<a name="175974980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175974980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175974980">(Sep 18 2019 at 06:35)</a>:</h4>
<p>I’ll have to review the thread.</p>



<a name="175975052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175975052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175975052">(Sep 18 2019 at 06:36)</a>:</h4>
<p>But I could imagine an issue arising with the dropck <em>implementation</em> due to the cyclic structure causing the compiler to loop</p>



<a name="175979747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175979747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175979747">(Sep 18 2019 at 07:51)</a>:</h4>
<p>The dropck is very imprecise, I don't think it can reason about this</p>



<a name="175979784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175979784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175979784">(Sep 18 2019 at 07:51)</a>:</h4>
<p>The issue in the nomicon is when you have a <code>&amp;'a i32</code> in a <code>Drop</code> the compiler does not know if the value it points to outlives the reference</p>



<a name="175979852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175979852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175979852">(Sep 18 2019 at 07:52)</a>:</h4>
<p>because that would mean it would need to outlive Drop::drop</p>



<a name="175980071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175980071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175980071">(Sep 18 2019 at 07:56)</a>:</h4>
<p>AFAIK we just bail here and require an unsafe Drop impl</p>



<a name="175984479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175984479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175984479">(Sep 18 2019 at 08:58)</a>:</h4>
<p>I'm still trying to understand the original issue being raised. Is the question about why dropck is only failing at the point where one has a <em>use</em> (i.e. instantiation) of <code>Perfect</code> ?</p>



<a name="175985503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175985503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175985503">(Sep 18 2019 at 09:13)</a>:</h4>
<p>That's how I understood the question</p>



<a name="175985574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175985574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175985574">(Sep 18 2019 at 09:14)</a>:</h4>
<p>A drop impl for perfect isn't bad per se, but depending on how it is used, the issue raised by the nomicon can appear - but that issue is essentially how the borrowck handles drop</p>



<a name="175986544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175986544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175986544">(Sep 18 2019 at 09:28)</a>:</h4>
<p>hmm. I am under the impression that dropck would fail in any <code>fn</code> body that attempts to instantiate <code>Perfect</code> with concrete types, regardless of what they are. But that is not what is implied by <span class="user-mention" data-user-id="116122">@simulacrum</span> 's question as I read it.</p>



<a name="175986576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175986576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175986576">(Sep 18 2019 at 09:28)</a>:</h4>
<p>but yes, currently the dropck works by analyzing concrete expressions, not abstract type definitions, and so by its nature you won't get these errors from the <code>enum</code> definition alone.</p>



<a name="175989750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175989750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175989750">(Sep 18 2019 at 10:13)</a>:</h4>
<p>My question is basically can dropck work, in theory, on type definitions, not concrete instantiations?</p>



<a name="175989959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175989959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175989959">(Sep 18 2019 at 10:17)</a>:</h4>
<p>the problem in this case, in theory, should be detected on the type definition</p>



<a name="175989967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175989967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175989967">(Sep 18 2019 at 10:17)</a>:</h4>
<p>In particular, I would expect us to be able to not check Perfect recursively; my assertion is that dropck should pass for any T in Perfect, i.e. that for all types T, U, dropck(Perfect&lt;T&gt;) = dropck(Perfect&lt;U&gt;). I'm not sure if this is true today, to be clear, I'm just saying that it seems like a correct impl of dropck could satisfy this property</p>



<a name="175990010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990010">(Sep 18 2019 at 10:18)</a>:</h4>
<p>because its fundamentally a type definition that is going to cause subsequent analyses to infinite loop</p>



<a name="175990037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990037">(Sep 18 2019 at 10:18)</a>:</h4>
<p>but the assertion  I am making there is not about dropck; it is about the nature of polymorphic recursion</p>



<a name="175990041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990041">(Sep 18 2019 at 10:18)</a>:</h4>
<p>I personally wouldn't expect a dropck error on this type</p>



<a name="175990070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990070">(Sep 18 2019 at 10:19)</a>:</h4>
<p>If my understanding of how dropck could work is correct</p>



<a name="175990072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990072">(Sep 18 2019 at 10:19)</a>:</h4>
<p>I want to be clear here: dropck is not rejecting this code, AFAIK. It is causing the compiler to <em>infinite loop</em></p>



<a name="175990101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990101">(Sep 18 2019 at 10:19)</a>:</h4>
<p>and that is because our attempt to detect cycles on the fly within dropck is not smart enough to catch cases like this</p>



<a name="175990141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990141">(Sep 18 2019 at 10:20)</a>:</h4>
<p>Right, well, loop really slowly - it will terminate due to the type depth limit</p>



<a name="175990162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990162">(Sep 18 2019 at 10:20)</a>:</h4>
<p>okay, sure.</p>



<a name="175990172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990172">(Sep 18 2019 at 10:20)</a>:</h4>
<p>I don't consider that to be "dropck is rejecting this code"</p>



<a name="175990197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990197">(Sep 18 2019 at 10:20)</a>:</h4>
<p>I consider that to be "the type definition is causing the compiler to have fits"</p>



<a name="175990204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990204">(Sep 18 2019 at 10:20)</a>:</h4>
<p>I suppose it is a somewhat subtle/subjective judgement</p>



<a name="175990241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990241">(Sep 18 2019 at 10:21)</a>:</h4>
<p>Okay, sure. But am I correct that dropck could work without any problems here, and in all cases, solely by analyzing the definition of Perfect?</p>



<a name="175990296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990296">(Sep 18 2019 at 10:22)</a>:</h4>
<p>anyway, dropck, or at least part of it, is about analyzing how a concrete variable (of a given type) is used in a body of code. So no, you cannot do all of dropck solely by analyzing the type definition</p>



<a name="175990418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990418">(Sep 18 2019 at 10:24)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> you keep mentioning this desired property that all types T, U, dropck(Perfect&lt;T&gt;) = dropck(Perfect&lt;U&gt;). But this confuses me, because, as far as I can tell, dropck <em>is</em> behaving the same here regardless of how you instantiate <code>Perfect</code>: it is infinite looping for any choice of <code>T</code>/<code>U</code>, (or rather hitting type depth limit), right?</p>



<a name="175990485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990485">(Sep 18 2019 at 10:25)</a>:</h4>
<p>Kind of - I mention that because if it's true, then I would expect us to be able to avoid the looping by keeping the output of dropck generic</p>



<a name="175990510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990510">(Sep 18 2019 at 10:25)</a>:</h4>
<p>My personal claim is that we could, and should, add an <em>extra</em> analysis (that would run long before <code>dropck</code>) of type definitions like that of <code>Perfect</code> that would reject them as exhibiting non-uniform recursion (aka polymorphic recursion)</p>



<a name="175990568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990568">(Sep 18 2019 at 10:26)</a>:</h4>
<p>which is what <a href="https://github.com/rust-lang/rust/issues/4287" target="_blank" title="https://github.com/rust-lang/rust/issues/4287">#4287</a> is about, or at least is my interpretation of it</p>



<a name="175990578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990578">(Sep 18 2019 at 10:26)</a>:</h4>
<p>Why should we reject such types? Is it just "we're not ready to handle them yet"?</p>



<a name="175990627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990627">(Sep 18 2019 at 10:27)</a>:</h4>
<p>I guess I was coming at this from the perspective that a good fix is to make this code compile, not fail with a nice error message</p>



<a name="175990633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990633">(Sep 18 2019 at 10:27)</a>:</h4>
<p>well if any use of the type implies you need an infinite set of instantiations</p>



<a name="175990635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990635">(Sep 18 2019 at 10:27)</a>:</h4>
<p>then you have a problem</p>



<a name="175990689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990689">(Sep 18 2019 at 10:28)</a>:</h4>
<p>Languages that handle polymorphic recursion do it, as far as I know, by building method dictionaries at runtime</p>



<a name="175990698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990698">(Sep 18 2019 at 10:28)</a>:</h4>
<p>but we use static monomorphization</p>



<a name="175990709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990709">(Sep 18 2019 at 10:28)</a>:</h4>
<p>so you need to build all your vtables at compile time</p>



<a name="175990741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990741">(Sep 18 2019 at 10:28)</a>:</h4>
<p>see e.g. <a href="https://github.com/rust-lang/rust/issues/4287#issuecomment-218304293" target="_blank" title="https://github.com/rust-lang/rust/issues/4287#issuecomment-218304293">https://github.com/rust-lang/rust/issues/4287#issuecomment-218304293</a></p>



<a name="175990792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990792">(Sep 18 2019 at 10:29)</a>:</h4>
<p>of course some people do point out that one might be able to handle some instances (via a form of type erasure, so that a single vtable would suffice for an infinite number of instantiations)</p>



<a name="175990797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990797">(Sep 18 2019 at 10:29)</a>:</h4>
<p>Hm, okay, I think I understand now. So the action item here is to implement another type ck pass which will reject Perfect by indicating polymorphic recursion?</p>



<a name="175990805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990805">(Sep 18 2019 at 10:29)</a>:</h4>
<p>Yes, that is what I believe the action item to be</p>



<a name="175990910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990910">(Sep 18 2019 at 10:30)</a>:</h4>
<p>Okay, makes sense.</p>



<a name="175990948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990948">(Sep 18 2019 at 10:31)</a>:</h4>
<p>I will take a look at an implementation then</p>



<a name="175990950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990950">(Sep 18 2019 at 10:31)</a>:</h4>
<p>this is not a trivial analysis, though</p>



<a name="175990980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175990980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175990980">(Sep 18 2019 at 10:32)</a>:</h4>
<p>mainly because of cases where it arises due to mutual recursion between a set of distinct struct/enum definitions</p>



<a name="175991104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175991104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175991104">(Sep 18 2019 at 10:33)</a>:</h4>
<p>I don't think it's trivial, but I'm thinking that some sort of approach that avoids directly instantiating a T would work - basically, keeping track of loops at the non-subst applied type</p>



<a name="175991163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175991163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175991163">(Sep 18 2019 at 10:34)</a>:</h4>
<p>yes, we would definitely want a solution that works without needing to instantiate a <code>T</code>, I think.</p>



<a name="175991232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175991232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175991232">(Sep 18 2019 at 10:35)</a>:</h4>
<p>It seems like even a non-perfect pass would already be an improvement, too</p>



<a name="175991274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175991274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175991274">(Sep 18 2019 at 10:35)</a>:</h4>
<p>sure</p>



<a name="175991421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175991421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175991421">(Sep 18 2019 at 10:37)</a>:</h4>
<p>In theory I think once we have it the depth limits elsewhere could for the most part be raised/removed, too, right?</p>



<a name="175991430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175991430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175991430">(Sep 18 2019 at 10:37)</a>:</h4>
<p>maybe</p>



<a name="175991434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175991434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175991434">(Sep 18 2019 at 10:37)</a>:</h4>
<p>or</p>



<a name="175991435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175991435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175991435">(Sep 18 2019 at 10:37)</a>:</h4>
<p>yes</p>



<a name="175991441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175991441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175991441">(Sep 18 2019 at 10:37)</a>:</h4>
<p>probably</p>



<a name="175991443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175991443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175991443">(Sep 18 2019 at 10:37)</a>:</h4>
<p>i don't know</p>



<a name="175991446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175991446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175991446">(Sep 18 2019 at 10:37)</a>:</h4>
<p><span aria-label="smile" class="emoji emoji-263a" role="img" title="smile">:smile:</span></p>



<a name="175991506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175991506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175991506">(Sep 18 2019 at 10:38)</a>:</h4>
<p>I guess they could still catch other cases - bugs in compiler, or so</p>



<a name="175991542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175991542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175991542">(Sep 18 2019 at 10:39)</a>:</h4>
<p>Anyway, I need to run, thanks for clarifying things for me</p>



<a name="175991829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175991829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175991829">(Sep 18 2019 at 10:42)</a>:</h4>
<p>dropck(Perfect&lt;T&gt;) is not really a thing</p>



<a name="175991871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175991871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175991871">(Sep 18 2019 at 10:43)</a>:</h4>
<p>Depending on how an expression uses the type, the expression might be incorrect, e.g., because the type might be missing an <code>unsafe Drop</code> impl</p>



<a name="175991890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175991890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175991890">(Sep 18 2019 at 10:44)</a>:</h4>
<p>We can't know that from looking at <code>Perfect&lt;T&gt;</code></p>



<a name="175992071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175992071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175992071">(Sep 18 2019 at 10:46)</a>:</h4>
<p>So what dropck a looks at are expressions using <code>Perfect&lt;T&gt;</code></p>



<a name="175992337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175992337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175992337">(Sep 18 2019 at 10:50)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> my impression is that dropck for Perfect&lt;T&gt; at best would return "perfect is good, also, check Box&lt;Perfect&lt;(T, T)&gt;&gt;</p>



<a name="175992350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175992350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175992350">(Sep 18 2019 at 10:51)</a>:</h4>
<p>And T I guess</p>



<a name="175992354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175992354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175992354">(Sep 18 2019 at 10:51)</a>:</h4>
<p>What would dropck check for a type ?</p>



<a name="175992410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175992410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175992410">(Sep 18 2019 at 10:52)</a>:</h4>
<p>Hm, well, it could conclude for a type with Phantom Data that it's just fine</p>



<a name="175992423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175992423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175992423">(Sep 18 2019 at 10:52)</a>:</h4>
<p>If I recall that bit correctly</p>



<a name="175992467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175992467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175992467">(Sep 18 2019 at 10:53)</a>:</h4>
<p>PhantomData&lt;T&gt; just says, this type should look like it owns a T</p>



<a name="175992551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175992551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175992551">(Sep 18 2019 at 10:54)</a>:</h4>
<p>but whether it matters will depend on whether the type actually has a Drop impl or not</p>



<a name="175992589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175992589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175992589">(Sep 18 2019 at 10:55)</a>:</h4>
<p>and also about how the type is actually used</p>



<a name="175992595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175992595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175992595">(Sep 18 2019 at 10:55)</a>:</h4>
<p>the dropck will say for some function, that that function uses the type correctly</p>



<a name="175992597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175992597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175992597">(Sep 18 2019 at 10:56)</a>:</h4>
<p>but for a different one, that it uses it incorrectly</p>



<a name="175992704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175992704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175992704">(Sep 18 2019 at 10:57)</a>:</h4>
<p>Sure - there's two parts to dropck though afaict, the generic piece and the concrete piece</p>



<a name="175992720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175992720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175992720">(Sep 18 2019 at 10:57)</a>:</h4>
<p>Oh, yeah, I remembered why we treated phantom specially, it's because it doesn't have fields</p>



<a name="175992771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175992771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175992771">(Sep 18 2019 at 10:58)</a>:</h4>
<p>Not only, the phantomdata also says that this type has data of type T</p>



<a name="175992785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175992785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175992785">(Sep 18 2019 at 10:58)</a>:</h4>
<p>and that information is used when evaluating whether a Drop impl is correct or not</p>



<a name="175992812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175992812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175992812">(Sep 18 2019 at 10:59)</a>:</h4>
<p>See here (<a href="https://doc.rust-lang.org/nomicon/dropck.html" target="_blank" title="https://doc.rust-lang.org/nomicon/dropck.html">https://doc.rust-lang.org/nomicon/dropck.html</a>):</p>
<blockquote>
<p>For a generic type to soundly implement drop, its generics arguments must strictly outlive it.</p>
</blockquote>



<a name="175992878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175992878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175992878">(Sep 18 2019 at 11:00)</a>:</h4>
<p>If you are taking references, that's always the case if the reference is <code>'static</code>, but if you have a <code>&lt;'a&gt;</code>, then you can't know just by looking at the type</p>



<a name="175992904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175992904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175992904">(Sep 18 2019 at 11:00)</a>:</h4>
<p>Each time the type is used, a different lifetime is passed, and depending on what the code does, the value passed might or might not outlive the type</p>



<a name="175993058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175993058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175993058">(Sep 18 2019 at 11:03)</a>:</h4>
<p>(it also depends on <code>#[may_dangle]</code>, etc.)</p>



<a name="175993259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175993259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175993259">(Sep 18 2019 at 11:07)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/8bf776d5c2fc88624d2562e493aab0d324a3b7d8/src/librustc_typeck/check/dropck.rs#L236" target="_blank" title="https://github.com/rust-lang/rust/blob/8bf776d5c2fc88624d2562e493aab0d324a3b7d8/src/librustc_typeck/check/dropck.rs#L236">https://github.com/rust-lang/rust/blob/8bf776d5c2fc88624d2562e493aab0d324a3b7d8/src/librustc_typeck/check/dropck.rs#L236</a></p>



<a name="175993324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175993324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175993324">(Sep 18 2019 at 11:08)</a>:</h4>
<p>The dropck is like the borrowck, it works on expressions</p>



<a name="175994389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175994389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175994389">(Sep 18 2019 at 11:24)</a>:</h4>
<p>Right, but it seems like "generic arguments must strictly outlive" can be checked without recursing into the type, whereas the current implementation does recurse</p>



<a name="175995663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175995663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175995663">(Sep 18 2019 at 11:40)</a>:</h4>
<p>Okay so its possible that part of my (our?) confusion in this conversation is arising because there are multiple things that one might say are computed as part of so-called "dropck"</p>



<a name="175995717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175995717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175995717">(Sep 18 2019 at 11:41)</a>:</h4>
<p>There is are two main things I can think of, off the top of my head</p>



<a name="175995742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175995742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175995742">(Sep 18 2019 at 11:41)</a>:</h4>
<p>1. the checking that a destructor doesn't run at a time where there may be a dangling pointer. This is fundamentally connecting to analyzing expressions</p>



<a name="175995807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175995807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175995807">(Sep 18 2019 at 11:42)</a>:</h4>
<p>(and may be why <span class="user-mention" data-user-id="132920">@gnzlbg</span> and I are both confused by the idea of doing dropck on the type declaration alone)</p>



<a name="175995874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175995874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175995874">(Sep 18 2019 at 11:43)</a>:</h4>
<p>2. the implied outlives bounds (and maybe also "strictly outlives" stuff discussed in the dropck RFC) that arise on the type parameters of a type due to that type, or some type reachable via its fields, implementing <code>Drop</code></p>



<a name="175996074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996074">(Sep 18 2019 at 11:45)</a>:</h4>
<p>Yes, I think the code I was talking about mostly looks at (2) -- in some sense, (1) is less interesting, as I would imagine it is sort of "part" of borrowck, in that it does very similar work</p>



<a name="175996083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996083">(Sep 18 2019 at 11:45)</a>:</h4>
<p>that second thing sounds more like what <span class="user-mention" data-user-id="116122">@simulacrum</span> is saying they would expect to be derived from an analysis of the type definition alone.</p>



<a name="175996204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996204">(Sep 18 2019 at 11:47)</a>:</h4>
<p>I guess I'm also saying that the first should be able to re-use information from the second, too</p>



<a name="175996234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996234">(Sep 18 2019 at 11:47)</a>:</h4>
<p>i.e., we should not need to recursively visit fields when dropck-ing an expression, rather just query "what types are needed to outlive for this to drop"</p>



<a name="175996245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996245">(Sep 18 2019 at 11:47)</a>:</h4>
<p>just catching up on the discussion: there seem like there are two issues here<br>
- type definitions that require an infinite list of instantiations (e.g. <code>T1&lt;T2&lt;T1&lt;...</code>) through polymorphic recursion<br>
- dropck not handling polymorphic recursion (even the finite kind) properly</p>



<a name="175996323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996323">(Sep 18 2019 at 11:48)</a>:</h4>
<p><code>Perfect</code>, for instance, doesn't seem to require an infinite list of instantiations, and looks fine in theory</p>



<a name="175996330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996330">(Sep 18 2019 at 11:48)</a>:</h4>
<p>so it seems like an implementation flaw more than a design flaw</p>



<a name="175996343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996343">(Sep 18 2019 at 11:48)</a>:</h4>
<p>FWIW, this type <code>struct&lt;'a&gt;(*mut &amp;'a T)</code> contains a type parameter, but no reference</p>



<a name="175996382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996382">(Sep 18 2019 at 11:49)</a>:</h4>
<p>So one really needs to check whether any field actually stores a reference AFAICT (that does not mean that one needs to recurse forever to determine that for Perfect though)</p>



<a name="175996386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996386">(Sep 18 2019 at 11:49)</a>:</h4>
<p>Yes, but the (2) pass could tell us that said type does not depend on T</p>



<a name="175996397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996397">(Sep 18 2019 at 11:49)</a>:</h4>
<p>i.e. does not need to outlive T</p>



<a name="175996407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996407">(Sep 18 2019 at 11:49)</a>:</h4>
<p>why is dropck something that's not part of the type system?</p>



<a name="175996416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996416">(Sep 18 2019 at 11:49)</a>:</h4>
<p>it seems we could have more details lifetimes</p>



<a name="175996429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996429">(Sep 18 2019 at 11:49)</a>:</h4>
<p>e.g. <code>'a.'b</code> for fine-grained ordering</p>



<a name="175996460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996460">(Sep 18 2019 at 11:50)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span> I'm not sure we can compile <code>Perfect</code> today, even if we side-stepped dropck.</p>



<a name="175996466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996466">(Sep 18 2019 at 11:50)</a>:</h4>
<p>one part should be part of borrowck, and the other of typeck</p>



<a name="175996491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996491">(Sep 18 2019 at 11:50)</a>:</h4>
<p>which would then allow us to do the dropck analysis on the types rather than the expressions</p>



<a name="175996562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996562">(Sep 18 2019 at 11:51)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span>: integrating with both typeck and borrowck</p>



<a name="175996563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996563">(Sep 18 2019 at 11:51)</a>:</h4>
<blockquote>
<p>Perfect, for instance, doesn't seem to require an infinite list of instantiations, and looks fine in theory</p>
</blockquote>
<p>I was convinced this is not true by <span class="user-mention" data-user-id="116083">@pnkfelix</span>'s argument that we'd need to codegen methods for Perfect&lt;(i32, i32)&gt; and Perfect&lt;((i32, i32), (i32, i32))&gt; etc</p>



<a name="175996575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996575">(Sep 18 2019 at 11:51)</a>:</h4>
<p>since, <em>i think</em>, compiling <code>{ let a: Perfect&lt;u32&gt;; ... }</code> would requiring emitting glue code to drop <code>Box&lt;Perfect&lt;(u32, u32)&gt;&gt;</code> ... and <code>Box&lt;Perfect&lt;((u32, u32), (u32, u32))&gt;&gt;</code>. etc</p>



<a name="175996591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996591">(Sep 18 2019 at 11:51)</a>:</h4>
<p>this is why I brought up the need to create vtables at runtime.</p>



<a name="175996594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996594">(Sep 18 2019 at 11:51)</a>:</h4>
<p>ah, I see</p>



<a name="175996649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996649">(Sep 18 2019 at 11:52)</a>:</h4>
<p>Languages that handle method-dispatch by passing along a dictionary can do this</p>



<a name="175996650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996650">(Sep 18 2019 at 11:52)</a>:</h4>
<p>but doing that still does not require dropck to infinitely recurse right ?</p>



<a name="175996659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996659">(Sep 18 2019 at 11:52)</a>:</h4>
<p>as in, maybe codegen fails later due to this</p>



<a name="175996675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996675">(Sep 18 2019 at 11:52)</a>:</h4>
<p>but neither of dropck passes should fail</p>



<a name="175996676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996676">(Sep 18 2019 at 11:52)</a>:</h4>
<p>(and I could imagine a new Rust calling ABI that would pass along a dictionary, and then dynamically create new ones when necessary)</p>



<a name="175996678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996678">(Sep 18 2019 at 11:52)</a>:</h4>
<p>Yes, I think we agree that <em>dropck</em> should maybe not fail on this type (it seems to satisfy dropck requirements), but we should provide a good error regardless</p>



<a name="175996697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996697">(Sep 18 2019 at 11:53)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> yes, I agree that the fact that dropck is infinitely recursing is a bug <em>somewhere</em></p>



<a name="175996722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996722">(Sep 18 2019 at 11:53)</a>:</h4>
<p>maybe its worth it to consider these as separate bugs and fill them separately</p>



<a name="175996723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996723">(Sep 18 2019 at 11:53)</a>:</h4>
<p>but my claim is that my ideal approach would be to detect the polymorphic recursion (at the point where the type is declared)</p>



<a name="175996726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996726">(Sep 18 2019 at 11:53)</a>:</h4>
<p>and error on it</p>



<a name="175996728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996728">(Sep 18 2019 at 11:53)</a>:</h4>
<p>the issue discussing Perfect is quite long</p>



<a name="175996737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996737">(Sep 18 2019 at 11:53)</a>:</h4>
<p>rather than attempting to generalize dropck to handle cases that should not arise in the first place.</p>



<a name="175996744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996744">(Sep 18 2019 at 11:53)</a>:</h4>
<p>ah, dunno</p>



<a name="175996784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996784">(Sep 18 2019 at 11:54)</a>:</h4>
<p>Yes, I agree -- it seems like there's just the one bug here, we don't have a polymorphic recursion detector</p>



<a name="175996788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996788">(Sep 18 2019 at 11:54)</a>:</h4>
<p>that's kind of a lang team thing</p>



<a name="175996807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996807">(Sep 18 2019 at 11:54)</a>:</h4>
<p>is there no case of polymorphic recursion that we support ?</p>



<a name="175996810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996810">(Sep 18 2019 at 11:54)</a>:</h4>
<p>I think it's just a matter of diagnostics?</p>



<a name="175996830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996830">(Sep 18 2019 at 11:54)</a>:</h4>
<p>To my knowledge you can't polymorphically recurse today without leading to dropck problems</p>



<a name="175996843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996843">(Sep 18 2019 at 11:54)</a>:</h4>
<p>I think the lack of polymorphic recursion is a compiler limitation, and choosing to forbid it is a lang decision</p>



<a name="175996875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996875">(Sep 18 2019 at 11:55)</a>:</h4>
<p>But we already forbid it today? Like, it would be a lang team decision to do the work to enable it, but we're talking about providing a better lint</p>



<a name="175996877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996877">(Sep 18 2019 at 11:55)</a>:</h4>
<p>from a user's perspective, if there aren't special drop rules for <code>Perfect</code>, it doesn't really make sense that you can't define it</p>



<a name="175996892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996892">(Sep 18 2019 at 11:55)</a>:</h4>
<p>we don't forbid it – it just doesn't work</p>



<a name="175996900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996900">(Sep 18 2019 at 11:55)</a>:</h4>
<p>e.g. Perfect&lt;T: Foo&gt;  { one(T), Second(Perfect&lt;(T::Other, T::Other)&gt;) }</p>



<a name="175996905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996905">(Sep 18 2019 at 11:55)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> the problem is that we don't today forbid the type declaration</p>



<a name="175996919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996919">(Sep 18 2019 at 11:55)</a>:</h4>
<p>we just fail to handle uses of it</p>



<a name="175996921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996921">(Sep 18 2019 at 11:55)</a>:</h4>
<p>Right, we could structure the lint to only error on invalid uses, in theory</p>



<a name="175996923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175996923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175996923">(Sep 18 2019 at 11:55)</a>:</h4>
<p>where at some point you get a tuple that implements Foo and Foo::Other = ! (and you keep recursing creating tuples of ! after that point, but that doesn't do anything)</p>



<a name="175997013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997013">(Sep 18 2019 at 11:56)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> that seems like a harder case, but yes, in theory, although I'm not entirely sure we'd handle ((!, !), (!, !))... etc well either</p>



<a name="175997038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997038">(Sep 18 2019 at 11:57)</a>:</h4>
<p>maybe just  `Perfect&lt;T: Foo&gt; { one(T), Second(T::Other) }  where T::Other could be Perfect&lt;..&gt; and at some point some T::Other is just () stopping recursion</p>



<a name="175997059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997059">(Sep 18 2019 at 11:57)</a>:</h4>
<p>Sure, yeah. Given something like that we do need to check concrete instantiations</p>



<a name="175997070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997070">(Sep 18 2019 at 11:57)</a>:</h4>
<p>that recursion is not infinite though</p>



<a name="175997076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997076">(Sep 18 2019 at 11:58)</a>:</h4>
<p>But it does seem like we can detect the Perfect case as-is and error out rather than stalling</p>



<a name="175997081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997081">(Sep 18 2019 at 11:58)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> wait, what was your example meant to show?</p>



<a name="175997121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997121">(Sep 18 2019 at 11:58)</a>:</h4>
<p>(deleted)</p>



<a name="175997126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997126">(Sep 18 2019 at 11:58)</a>:</h4>
<p>that its hard to detect the error in all cases? (without breaking valid code, that is)</p>



<a name="175997142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997142">(Sep 18 2019 at 11:58)</a>:</h4>
<p>e.g. <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=70084f5ad3f6ca8d931285551b1d465a" target="_blank" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=70084f5ad3f6ca8d931285551b1d465a">this</a> compiles.</p>



<a name="175997151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997151">(Sep 18 2019 at 11:58)</a>:</h4>
<p>and thus you wouldn't want to reject it.</p>



<a name="175997206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997206">(Sep 18 2019 at 11:59)</a>:</h4>
<p>so how is that different than the original example ?</p>



<a name="175997207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997207">(Sep 18 2019 at 11:59)</a>:</h4>
<p>(note that this is <strong>not</strong> an re-encoding of the <code>Perfect</code> example we are discussing. in particular it changes associated type for the tuple to u32, thus avoiding infinite regress)</p>



<a name="175997217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997217">(Sep 18 2019 at 11:59)</a>:</h4>
<p>Sure, yes. Though I would argue that we should be able to detect that there's a difference between this and the original Perfect</p>



<a name="175997330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997330">(Sep 18 2019 at 12:00)</a>:</h4>
<p>ah yes</p>



<a name="175997362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997362">(Sep 18 2019 at 12:01)</a>:</h4>
<p>(I should have alpha-renamed <code>Perfect</code> before sharing it)</p>



<a name="175997450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997450">(Sep 18 2019 at 12:02)</a>:</h4>
<p>(I suspect that higher-kinded types, and how they are currently expressed via associated items, are going to be the big hurdle to overcome in an attempt to detect polymorphic recursion solely via analysis of the type declarations.)</p>



<a name="175997493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997493">(Sep 18 2019 at 12:03)</a>:</h4>
<p>seems like, in theory, if we could express <code>T: !Drop</code>, then the recursion wouldn't be an issue?</p>



<a name="175997522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997522">(Sep 18 2019 at 12:03)</a>:</h4>
<p>I think our belief is that _even if_ dropck didn't error here, that wouldn't matter</p>



<a name="175997528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997528">(Sep 18 2019 at 12:03)</a>:</h4>
<p>we would error somewhere else</p>



<a name="175997531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997531">(Sep 18 2019 at 12:03)</a>:</h4>
<p>I mean in terms of generating infinite impls during monomorphisation</p>



<a name="175997584"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997584" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997584">(Sep 18 2019 at 12:04)</a>:</h4>
<p>Well, even if T is not Drop, Box&lt;T&gt; is, so you need to codegen infinite impls for Box, right?</p>



<a name="175997591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997591">(Sep 18 2019 at 12:04)</a>:</h4>
<blockquote>
<p>Sure, yes. Though I would argue that we should be able to detect that there's a difference between this and the original Perfect</p>
</blockquote>
<p>Yes, I do believe we should be able to catch infinitely-regressing polymorphic recursion as exemplified in the original <code>Perfect&lt;T&gt; { Tip(T), Fork(Box&lt;Perfect&lt;(T, T)&gt;&gt;) }</code> via some semi-straight-forward analysis.</p>



<a name="175997619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997619">(Sep 18 2019 at 12:04)</a>:</h4>
<blockquote>
<p>Well, even if T is not Drop, Box&lt;T&gt; is, so you need to codegen infinite impls for Box, right?</p>
</blockquote>
<p>I suppose anywhere we call a method on the generic parameter, it's going to start recursing...</p>



<a name="175997670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997670">(Sep 18 2019 at 12:05)</a>:</h4>
<p>yeah, I think it is safe to forbid types of the pattern <code>Perfect&lt;T&gt; { Tip(T), Fork(Box&lt;Perfect&lt;(T, T)&gt;&gt;) }</code> -- yes, there are similar-looking but not actually wrong patterns, but if we can avoid those then that's good</p>



<a name="175997797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997797">(Sep 18 2019 at 12:07)</a>:</h4>
<p>I actually think <span class="user-mention" data-user-id="121053">@varkor</span>  has the right intuition</p>



<a name="175997810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997810">(Sep 18 2019 at 12:07)</a>:</h4>
<p>in that, if you can get rid of the drop-glue</p>



<a name="175997815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997815">(Sep 18 2019 at 12:07)</a>:</h4>
<p>then the problem does go away</p>



<a name="175997956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175997956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175997956">(Sep 18 2019 at 12:09)</a>:</h4>
<p>_for dropck_ yes, but not for arbitrary (recursive?) methods, right?</p>



<a name="175998120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998120">(Sep 18 2019 at 12:10)</a>:</h4>
<p>heh</p>



<a name="175998130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998130">(Sep 18 2019 at 12:10)</a>:</h4>
<p>Though one could imagine that would be orthogonal, and for drop-glue of Box for example we have the #[may_dangle] on T so in theory there's just one impl (though that could be a lie, due to being compiler-implemented</p>



<a name="175998151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998151">(Sep 18 2019 at 12:11)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">enum</span> <span class="nc">Perfect</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">Tip</span><span class="p">(</span><span class="n">T</span><span class="p">),</span><span class="w"> </span><span class="n">Fork</span><span class="p">(</span><span class="nb">Box</span><span class="o">&lt;</span><span class="n">Perfect</span><span class="o">&lt;</span><span class="p">(</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">T</span><span class="p">)</span><span class="o">&gt;&gt;</span><span class="p">)</span><span class="w"> </span><span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Perfect</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">if</span><span class="w"> </span><span class="kc">true</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="bp">self</span><span class="p">.</span><span class="n">foo</span><span class="p">();</span><span class="w"> </span><span class="c1">// impl&lt;(T, T)&gt;</span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">bar</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Perfect</span>::<span class="n">Tip</span><span class="p">(</span><span class="mi">0</span><span class="k">u32</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="n">foo</span><span class="p">(</span><span class="n">p</span><span class="p">);</span><span class="w"> </span><span class="c1">// impl&lt;u32&gt;</span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="175998169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998169">(Sep 18 2019 at 12:11)</a>:</h4>
<p>something like this presents the problem even without dropck, I think</p>



<a name="175998240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998240">(Sep 18 2019 at 12:12)</a>:</h4>
<p>ah</p>



<a name="175998283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998283">(Sep 18 2019 at 12:12)</a>:</h4>
<p>I was trying to make an examle</p>



<a name="175998300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998300">(Sep 18 2019 at 12:12)</a>:</h4>
<p>but I was putting <code>#[derive(Debug)]</code> on <code>enum Perfect</code></p>



<a name="175998313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998313">(Sep 18 2019 at 12:12)</a>:</h4>
<p>and that was a no-no</p>



<a name="175998333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998333">(Sep 18 2019 at 12:12)</a>:</h4>
<p>or ..</p>



<a name="175998354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998354">(Sep 18 2019 at 12:12)</a>:</h4>
<p>well never mind, let me wait until I actually get this example to work</p>



<a name="175998642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998642">(Sep 18 2019 at 12:16)</a>:</h4>
<p>okay this seems weird to me: <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=cd7f7628072a2e14e0967a259150d4ca" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=cd7f7628072a2e14e0967a259150d4ca">badness</a></p>



<a name="175998699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998699">(Sep 18 2019 at 12:17)</a>:</h4>
<p>sorry, add a call to the <code>but_this_doesnt</code> from main to see the "error", if it can be called that (is it a timeout?)</p>



<a name="175998713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998713">(Sep 18 2019 at 12:17)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=d6026a8d14d2741dc9fb8b18c2bec3f5" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=d6026a8d14d2741dc9fb8b18c2bec3f5">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=d6026a8d14d2741dc9fb8b18c2bec3f5</a></p>



<a name="175998813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998813">(Sep 18 2019 at 12:18)</a>:</h4>
<p>hm, yeah, it compiles locally</p>



<a name="175998817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998817">(Sep 18 2019 at 12:19)</a>:</h4>
<p>so I suspect memory limit I think</p>



<a name="175998827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998827">(Sep 18 2019 at 12:19)</a>:</h4>
<p>timeout usually gives a different error</p>



<a name="175998836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998836">(Sep 18 2019 at 12:19)</a>:</h4>
<p>yikes</p>



<a name="175998861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998861">(Sep 18 2019 at 12:19)</a>:</h4>
<p>(we give like 100MB or so on play, so that's not too surprising)</p>



<a name="175998965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998965">(Sep 18 2019 at 12:20)</a>:</h4>
<p>113 MB at max used based on local testing</p>



<a name="175998969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998969">(Sep 18 2019 at 12:20)</a>:</h4>
<p>so just over</p>



<a name="175998974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998974">(Sep 18 2019 at 12:20)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=dc4224992e936c8bc1b4d1d2f884bf2a" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=dc4224992e936c8bc1b4d1d2f884bf2a">this</a> is what I wanted to demo, in that it shows a value being constructed</p>



<a name="175998978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998978">(Sep 18 2019 at 12:20)</a>:</h4>
<p>and then calling a method on it</p>



<a name="175998999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175998999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175998999">(Sep 18 2019 at 12:20)</a>:</h4>
<p>ah, release mode compiles in playpen</p>



<a name="175999048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999048">(Sep 18 2019 at 12:21)</a>:</h4>
<p>that case compiles locally for me as well, yes, though it's worth noting that we would not consider this a problem from e.g. dropck due to the indirection</p>



<a name="175999096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999096">(Sep 18 2019 at 12:22)</a>:</h4>
<p>and okay, you get problems if you try to call the generate fmt::Debug routine for the <code>Fork</code> variant's payload</p>



<a name="175999119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999119">(Sep 18 2019 at 12:22)</a>:</h4>
<p>Right, you can't instantiate anything that treats this generically I'd guess and calls "itself"</p>



<a name="175999156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999156">(Sep 18 2019 at 12:23)</a>:</h4>
<p>(<a href="https://play.rust-lang.org/?version=nightly&amp;mode=release&amp;edition=2018&amp;gist=ca701faf47416b4c10479ee2296b0bbd" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=release&amp;edition=2018&amp;gist=ca701faf47416b4c10479ee2296b0bbd">demo</a> of fmt::Debug infinite regress). Yes I agree with that</p>



<a name="175999196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999196">(Sep 18 2019 at 12:23)</a>:</h4>
<blockquote>
<p>though it's worth noting that we would not consider this a problem from e.g. dropck due to the indirection</p>
</blockquote>
<p>right; this is what I was trying to work my way towards when I said that I thought <span class="user-mention" data-user-id="121053">@varkor</span> had the right intuition about the problems here not arising if you're dealing with types that are <code>!Drop</code></p>



<a name="175999265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999265">(Sep 18 2019 at 12:24)</a>:</h4>
<p>so that's an example where you <em>can</em> have polymorphic recursion today</p>



<a name="175999294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999294">(Sep 18 2019 at 12:24)</a>:</h4>
<p>a lot of the standard stuff (like <code>derive(Debug)</code>) won't play well with it</p>



<a name="175999298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999298">(Sep 18 2019 at 12:25)</a>:</h4>
<p>but that's not the same as "not supported in the language."</p>



<a name="175999308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999308">(Sep 18 2019 at 12:25)</a>:</h4>
<p>hm, sure, but you need to be sort of "very careful" and in fact, not actually have it</p>



<a name="175999319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999319">(Sep 18 2019 at 12:25)</a>:</h4>
<p>i.e. if you attempt to use the fact you have it then it breaks :)</p>



<a name="175999321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999321">(Sep 18 2019 at 12:25)</a>:</h4>
<p>why do you say "not actually have it" ?</p>



<a name="175999346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999346">(Sep 18 2019 at 12:25)</a>:</h4>
<blockquote>
<p>i.e. if you attempt to use the fact you have it then it breaks :)</p>
</blockquote>
<p>does that clarify?</p>



<a name="175999354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999354">(Sep 18 2019 at 12:25)</a>:</h4>
<p>not sure yet</p>



<a name="175999412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999412">(Sep 18 2019 at 12:26)</a>:</h4>
<p>my intuition is that the breakage I demoed there is more an artifact of how <code>derive</code> works</p>



<a name="175999416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999416">(Sep 18 2019 at 12:26)</a>:</h4>
<p>let me try a manual impl to double check my own intuition</p>



<a name="175999443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999443">(Sep 18 2019 at 12:27)</a>:</h4>
<p>well, I think it's because we're calling Debug::fmt on Perfect&lt;'a, X&gt;, which means we need to codegen impl for &amp;'a Perfect&lt;(X, X)&gt;</p>



<a name="175999449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999449">(Sep 18 2019 at 12:27)</a>:</h4>
<p>and so on</p>



<a name="175999454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999454">(Sep 18 2019 at 12:27)</a>:</h4>
<p>right, but that's just because of the derive code</p>



<a name="175999465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999465">(Sep 18 2019 at 12:27)</a>:</h4>
<p>in theory, you don't <em>have</em> to use a statically generated series of calls to do the debug formatting</p>



<a name="175999467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999467">(Sep 18 2019 at 12:27)</a>:</h4>
<p>I don't see how you could implement it differently? Like, there's no way to observe polymorphic recursion otherwise, right?</p>



<a name="175999534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999534">(Sep 18 2019 at 12:28)</a>:</h4>
<p>unless you mean like passing in *mut () that magically knows how to deal with it by at runtime generating the impl.. but that seems ~impossible to get right without compiler knowledge</p>



<a name="175999554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999554">(Sep 18 2019 at 12:29)</a>:</h4>
<p>sort of a #[may_dangle] for arbitrary impls, I guess, in some sense</p>



<a name="175999590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999590">(Sep 18 2019 at 12:29)</a>:</h4>
<p>I guess I'm envisaging someone implementing their own dictionary passing</p>



<a name="175999618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999618">(Sep 18 2019 at 12:29)</a>:</h4>
<p>which, okay, is at runtime generating the impl</p>



<a name="175999672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999672">(Sep 18 2019 at 12:30)</a>:</h4>
<p>but I'm not so sure it needs compiler magic</p>



<a name="175999707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/175999707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#175999707">(Sep 18 2019 at 12:30)</a>:</h4>
<p>You can't know the layout of the enum/struct/etc to be able to access the fields and recurse polymorphically, right?</p>



<a name="176000037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/176000037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#176000037">(Sep 18 2019 at 12:35)</a>:</h4>
<p>i'm not being clear; I'm still not convinced you would need to resort to such low-level trickery</p>



<a name="176000042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/176000042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#176000042">(Sep 18 2019 at 12:35)</a>:</h4>
<p>but I also have failed to make a working example</p>



<a name="176000080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/176000080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#176000080">(Sep 18 2019 at 12:36)</a>:</h4>
<p>so I'll spend a few more minutes playing around, and if that goes nowhere, I'll abandon ship</p>



<a name="176000201"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/176000201" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#176000201">(Sep 18 2019 at 12:37)</a>:</h4>
<p>hm, sounds good. I guess I don't see how you could avoid low-level trickery if you want to recursively visit or so</p>



<a name="176000211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/176000211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#176000211">(Sep 18 2019 at 12:37)</a>:</h4>
<p>okay, its definitely not <em>simple</em>, since, as we've already covered, you cannot rely on the compiler to generate the infinite set of type instantiations for you at compile time</p>



<a name="176000440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/176000440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#176000440">(Sep 18 2019 at 12:40)</a>:</h4>
<p>that's what I was trying to get at -- you'd need to do so at runtime (well, not infinite set, but the subset you "need") and in order to do so it seems like you need to know layout details for it to be useful</p>



<a name="176000455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/176000455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#176000455">(Sep 18 2019 at 12:40)</a>:</h4>
<p>I suppose you _could_ generate a constant depth at compiletime and call those methods</p>



<a name="176000471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/176000471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#176000471">(Sep 18 2019 at 12:41)</a>:</h4>
<p>that seems less useful though</p>



<a name="176000565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/176000565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#176000565">(Sep 18 2019 at 12:42)</a>:</h4>
<p>anyway, I do think we can eke out a polymorphic recursion detector though maybe it won't be as pretty as I was envisioning since we need to be more concrete (due to not actually wanting to forbid the type itself, only instantiations of it), but that seems mostly fine</p>



<a name="176000796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/176000796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#176000796">(Sep 18 2019 at 12:45)</a>:</h4>
<p>it's subtle if you want to detect instantiations, because they might be generated by <code>#[derive(Debug)]</code>, etc.</p>



<a name="176000812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/176000812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#176000812">(Sep 18 2019 at 12:45)</a>:</h4>
<p>so the diagnostics are going to have to be quite clever</p>



<a name="176002391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/176002391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#176002391">(Sep 18 2019 at 13:03)</a>:</h4>
<p>I bet you could still do quite well in analyzing the type itself and just looking for where you see mixing of drop with polymorphic recursion</p>



<a name="176002472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/176002472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#176002472">(Sep 18 2019 at 13:04)</a>:</h4>
<p>basically focus on the cases where the drop-glue is going to be impossible to emit</p>



<a name="176006882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/dropck%20optimization/near/176006882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/dropck.20optimization.html#176006882">(Sep 18 2019 at 13:53)</a>:</h4>
<p>Indeed, it won't catch everything but that's probably okay</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>